package com.ztk.threadbasic.volitale;

import java.util.concurrent.TimeUnit;

public class Volitale01 implements Runnable{

    private volatile boolean stop = false;

    @Override
    public void run() {
        while (!stop) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + "：执行中");
        }
    }

    public void setStop(boolean stop) {
        this.stop = stop;
    }
}
